<template>
  <div class="main">
    <!--头像-->
    <el-avatar :src="avatarUrl"></el-avatar>
    <div style="margin-left: 10px;">
      <div style="display:flex;align-items: center;">
        <!--昵称-->
        <div class="nickname">
          {{ contacts.nickname }}
        </div>
        <span v-if="contacts.unread" class="notify-number">{{ contacts.unread }}</span>
      </div>
      <!--最后一条消息-->
      <div class="msg" v-html="contacts.lastMsg"></div>
    </div>
  </div>
</template>

<script>
import { baseUrl } from '@/utils/const'

export default {
  name: 'Contacts',
  props: {
    contacts: {
      required: true
    }
  },
  computed: {
    avatarUrl () {
      return baseUrl + this.contacts.avatar
    }
  }
}
</script>

<style scoped lang="less">
.main {
  padding: 10px;
  height: 65px;
  background-color: @background;
  display: flex;
  align-items: center;

  .nickname {
    width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .notify-number {
    color: #fff;
    line-height: 16px;
    font-size: 12px;
    border-radius: 8px;
    height: 16px;
    min-width: 16px;
    padding: 0 4px;
    text-align: center;
    background-color: #fb7299;
  }

  .msg {
    width: 170px;
    margin-top: 8px;
    color: @menuText_gray;
    font-size: small;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.main:hover {
  cursor: pointer;
  background-color: @gray-p;
}

</style>
